/**
 * @Company: 北京慧点科技有限公司 | www.smartdot.com.cn
 * @Copyright 1998-2020 © Smartdot Technologies Co., Ltd.
 */
package com.springlearn.zhoufei.other.spring.demo2;


import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

@Configurable//相当于Bean2.xml
public class HelloWorld8_1 {
    @Bean
    public HelloWorld7 HelloWorld7() {
        return new HelloWorld7();
    }
    @Bean
    public HelloWorld8 HelloWorld8() {
        //通过构造函数注入依赖
        //HelloWorld8方法调用HelloWorld7方法
        return new HelloWorld8(HelloWorld7());
    }

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorld8_1.class);
        HelloWorld8 HelloWorld8 = context.getBean(HelloWorld8.class);
        System.out.println(HelloWorld8.toString());
        System.out.println(HelloWorld8.getHelloWorld7().toString());

    }
}